﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sustainalytics.DW.Synchronization
{
    public static class EnumerableExtensions
    {
        public static IEnumerable<List<T>> Batch<T>(this IEnumerable<T> items, int count)
        {
            return items.Select((item, index) => new { item, index })
                        .GroupBy(x => x.index / count)
                        .Select(g => g.Select(x => x.item).ToList().ToList());
        }
    }
}
